<?php

class Core_Backend_Component_Global_View_Component_Index extends Core_Backend_Share_View_Grid {

    protected function buildToolbar($toolbar) {
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(NULL, 'install'), $this->__('global.button.install'));    	
    }

    protected function buildGrid($grid) {
        $grid->setId('component_grid')
                ->setPrimaryKey('id')
                ->addLabelColumn($this->__('share.label.name'), 'name', '{name}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('global.label.author'), 'author', '{author}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('global.label.company'), 'company', '{company}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('global.label.website'), 'website_name', '{website_name}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('global.label.version'), 'version', '{version}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('share.label.creator'), 'creator', '{creator}')
                ->setSortField('creator')
                ->setWidth(100)
                ->getGrid()
                ->addDatetimeColumn($this->__('catalogue.label.created_time'), 'created_time', '{created_time}')
                ->setWidth(100)
                ->setSortField('created_time')
                ->getGrid()
                ->addLinkColumn('#', 'uninstall', $this->getUrl(array('id' => '{id}'), 'uninstall'), $this->__('global.button.uninstall'))
                ->setWidth(40)
                ->setAlign('center')
                ->getGrid()
                ->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $url = $this->getPaginationUrl();
        $pagination->setUrlFormat($url)
                ->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }

}